package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    /**
     *  业务需求:  根据id查询商品分类信息
     *  url地址:   http://localhost:8091/item/cat/queryItemName?itemCatId=440
     *  参数:      itemCatId=440
     *  返回值:    返回商品分类名称
     */


    /**
     * SpringMVC 参数传递的本质
     * 问题:  itemCatId是如何当做参数进行的传递,框架如何实现???
     * @param itemCatId
     * @return
     *
     * <input  type="text" name="itemCatId"  value="100" />
     */

    @RequestMapping("/item/cat/queryItemName")
    public String findItemCatName(Long itemCatId){
        ItemCat itemCat =
                        itemCatService.findItemCatName(itemCatId);
        return itemCat.getName();
    }
}
